package com.hxzy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hxzy.entity.AddressBook;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * 客户的收货地址
 * @author Administrator
 */
@Mapper
@Repository
public interface AddressBookMapper extends BaseMapper<AddressBook> {

    AddressBook selectByPrimaryKey(Long id);


    @Update(value = "update address_book set is_deleted=1 where id=#{id}")
    int delete(Long id);

    /**
     * 取消当前用户所有的默认收货地址
     * @param userId
     * @return
     */
    @Update(value = "update address_book set is_default=0 where user_id=#{userId}")
    int cancelDefaultAddress(Long userId);

    /**
     * 设定当前地址为默认收货地址
     * @param id
     * @return
     */
    @Update(value = "update address_book set is_default=1 where id=#{id}")
    int updateDefaultAddress(Long id);
}